home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / Chip Temmuz 2004.iso / program / antispam / RazorAgent_SDK / razor-agents-sdk-2.03.exe / Time-HiRes-01.20 / t / 02export.t < prev   
Encoding:
Text File  |  1997-04-29  |  1.4 KB  |  59 lines

  1. # Before `make install' is performed this script should be runnable with
  2. # `make test'. After `make install' it should work as `perl test.pl'
  3.  
  4. ######################### We start with some black magic to print on failure.
  5.  
  6. BEGIN {
  7.     require Time::HiRes;
  8.     unless (defined &Time::HiRes::gettimeofday
  9.         && defined &Time::HiRes::ualarm
  10.         && defined &Time::HiRes::usleep) {
  11.         print "1..0\n";
  12.     exit;
  13.     }
  14. }
  15.  
  16. # Change 1..1 below to 1..last_test_to_print .
  17. # (It may become useful if the test is moved to ./t subdirectory.)
  18.  
  19. BEGIN { $| = 1; print "1..4\n"; }
  20. END {print "not ok 1\n" unless $loaded;}
  21.  
  22. $Exporter::Verbose=1;
  23. use Time::HiRes qw (time alarm sleep);
  24. $loaded = 1;
  25. print "ok 1\n";
  26.  
  27. ######################### End of black magic.
  28.  
  29. # Insert your test code below (better if it prints "ok 13"
  30. # (correspondingly "not ok 13") depending on the success of chunk 13
  31. # of the test code):
  32.  
  33. print "time...";
  34. $f = time; 
  35. print "$f\nok 2\n";
  36.  
  37. print "sleep...";
  38. $r = [Time::HiRes::gettimeofday];
  39. sleep (0.5);
  40. print Time::HiRes::tv_interval($r), "\nok 3\n";
  41.  
  42. $r = [Time::HiRes::gettimeofday];
  43. $i = 5;
  44. $SIG{ALRM} = "tick";
  45. while ($i)
  46.  {
  47.   alarm(2.5);
  48.   select (undef, undef, undef, 10);
  49.   print "Select returned! ", Time::HiRes::tv_interval ($r), "\n";
  50.  }
  51.  
  52. sub tick
  53.  {
  54.   print "Tick! ", Time::HiRes::tv_interval ($r), "\n";
  55.   $i--;
  56.  }
  57. $SIG{ALRM} = 'DEFAULT';
  58. print "ok 4\n";
  59.